
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--    <meta charset=utf-8">-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>数据库后台</title>
    <!-- BOOTSTRAP STYLES-->
<!--    <link href="../css/bootstrap.css" rel="stylesheet" />-->
    <link href="../css/bootstrap.min.css" rel="stylesheet" />
    <!-- CUSTOM STYLES-->
    <link href="../css/custom.css" rel="stylesheet" />
    <!-- /. WRAPPER  -->
    <!-- SCRIPTS -AT THE BOTOM TO REDUCE THE LOAD TIME-->
    <!-- JQUERY SCRIPTS -->
<!--    <script src="../js/jquery-1.7.1.min.js"></script>-->
    <!-- BOOTSTRAP SCRIPTS -->
<!--    <script src="../js/bootstrap.min.js"></script>-->
    <!-- METISMENU SCRIPTS -->
    <script src="../js/jquery.js"></script>
<!--    <script type="text/javascript" src="../js/bootstrap.min.js"charset="UTF-8"></script>-->
    <script src="../js/commonwap.js"></script>
</head>
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<body>
<div id="wrapper">
    <nav class="navbar navbar-default navbar-cls-top " role="navigation"
         style="margin-bottom: 0">
        <div style="color: white; padding: 15px 50px 5px 50px; float: left; font-size: 16px;">
            <div id = "meanu">菜单</div>
        </div>
        <div
                style="color: white; padding: 15px 50px 5px 50px; float: right; font-size: 16px;">
            <button id = "loginout" class="btn btn-danger">注销</button>
        </div>
    </nav>
    <div class="sidebar-collapse">
        <ul class="nav" id="main-menu" style="display: none" >
            <li><a href="formsubmit.html">表单录入</a></li>
            <li><a href="distribute.html"> 任务分配</a></li>
            <li><a href="feedback.html">   数据反馈</a></li>
            <li><a href="usermanage.html"> 用户管理</a></li>
            <li><a href="searchlist.html"> 数据查询</a></li>
        </ul>
    </div>
    <div id="page-wrapper">
        <div id="page-inner">

            <div class="container">
                <fieldset>
                    <legend>数据查询</legend>
                    <p>
                        <input type="button" id="searchlist" class="btn btn-primary" value="查找" />
<!--                        <input type="button" id="downloadlist" class="btn btn-primary" value="下载" />-->
                    </p>

                    <div class="row" style="padding: 50px 20px 0px 20px">

                        <div class="table-responsive">
                            <table class="table table-striped" id="tab"
                                   style="text-align: center">
                                <thead>
                                <td>姓名</td>
                                <td>手机号</td>
                                <td>QQ/微信</td>
                                <td>备注</td>
                                <td>关键词</td>
                                <td>所属项目</td>
                                <td>地区</td>
                                <td>录入时间</td>
                                <td>是否有效</td>
                                <td>客户意向</td>
                                <td>跟进人</td>
                                <td>修改跟进人</td>
                                </thead>
                                <tbody>


                                </tbody>
                            </table>
                        </div>
                    </div>
<!--                    <div class="col-sm-offset-5 col-sm-7">-->
<!--                        <input id="ebutton" type="button" value="导出EXCEL"-->
<!--                               onClick="getXlsFromJsp('table1')" class="btn btn-primary"-->
<!--                               style="display: none">-->
<!--                    </div>-->
                </fieldset>
            </div>


            <!--                    <h2>创建模态框（Modal）</h2>-->
            <!-- 按钮触发模态框 -->
            <!--                    <button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal" value="66666">开始演示模态框</button>-->
            <!-- 模态框（Modal） -->
            <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="myModalLabel">用户信息反馈</h4>
                        </div>
                        <div class="modal-body">跟进人
                            <select id="selectchoice">
                                <option value="null"></option>
                                <option value="1">是</option>
                                <option value="0">否</option>
                            </select>
                        <div><input style="display: none" id="displayid"/></div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            <button type="button" class="btn btn-primary" data-dismiss="modal" id="modify">提交更改</button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal -->
            </div>







            <!-- /. PAGE INNER  -->
        </div>
        <!-- /. PAGE WRAPPER  -->
    </div>
<!--    <script type="text/javascript" src="../js/AjaxAPI.js" charset="UTF-8"></script>-->
<!--    <script src="../js/jquery.dataTables.js"></script>-->
</div>
    <script type="text/javascript">
        $(document).ready(function () {

        $("#searchlist").click(function () {
            $.ajax({
                type: "POST",
                url: "../search/searchlist",
                // contentType: "application/json;charset=utf-8",
                dataType: "json",
                success:function (data) {
                    if(data==null){
                        // window.location.href = "/msgtable/html/login.html"
                        alert("无权限")
                    }else{
                        $('table tbody').html('');
                        $.each(data, function (i, item){
                            // alert(item.realName)

                            var _len = $("#tab tr").length;
                            $("#tab").append("<tr id="+_len+" align='center'>"
                                +"<td>"+item.realName               +"</td>"
                                +"<td>"+item.phone         +"</td>"
                                +"<td>"+item.qq      +"</td>"
                                +"<td>"+item.remarks          +"</td>"
                                +"<td>"+item.keyword           +"</td>"
                                +"<td>"+item.project            +"</td>"
                                +"<td>"+item.area      +"</td>"
                                +"<td>"+item.inputTime      +"</td>"
                                +"<td>"+item.isable           +"</td>"
                                +"<td>"+item.label        +"</td>"
                                +"<td>"+item.followUser         +"</td>"
                                + "<td><button class='btn btn-primary buttomval' name='valbtn' data-toggle='modal' data-target='#myModal' value="+item.id +">操作</button></td>"
                                +"</tr>");

                        })
                    }
                    // alert("提交成功"+JSON.stringify(message));
                    // alert("请冲")
                },
                error:function (data) {
                    // window.location.href = "/msgtable/html/login.html"
                    alert("无权限")
                }
            });
        });

        $(document).on('click','.buttomval',function(){

            $("#displayid").val($(this).val());
            $("#selectchoice").empty();
            $.ajax({
                type: "POST",
                url: "../login/searchFollowlist",
                contentType: "application/json;charset=utf-8",
                // data: JSON.stringify(d1),
                dataType: "json",
                success: function (data) {
                    if (data == null) {
                        // window.location.href = "/msgtable/html/login.html"
                        alert("无权限")
                    } else {
                        $("#selectchoice").prepend("<option value='0'>请选择</option>");
                        $.each(data, function (i, item) {
                            $("#selectchoice").append("<option value="+item.id+" id="+item.id+">"+item.realName+"</option>");
                        })
                    }
                },
                error: function (data) {
                    window.location.href = "/msgtable/html/login.html"
                    alert("请登录")
                }
            });

        })


        $("#modify").click(function () {
            // alert($("#selectchoice").val());
            var options = $("#selectchoice option:selected");
            // alert(options.val());
            // alert(options)
            let d1 = {
                id:$("#displayid").val(),
                followUser:options.val(),
            };
            $.ajax({
                type: "POST",
                url: "../distribute/partone",
                contentType: "application/json;charset=utf-8",
                data:JSON.stringify(d1),
                dataType: "text",
                success:function (data) {
                    alert(data)
                    $("#searchlist").click();
                },
                error:function (data) {
                    alert(data)
                }
            });
        });





        });
    </script>

</body>
</html>